<template>
	<view class="address_add">
		<view class="address_add_input">
			<textarea @input="address_discern_value_event" class="inptTex"
				placeholder="请输入或粘贴地址文本，自动识别姓名，电话和地址。如张三 15000000000 广东省深圳市罗湖区贝丽北路兴龙黄金珠宝大厦。" />
			<view class="input_but">
				<view class="but_item">清空内容</view>
				<view class="but_item">智能识别</view>
			</view>
		</view>
		<view class="info_list">
			<view class="list_int">
				<text>联系人：</text>
				<input type="text" v-model="name" placeholder="请输入名字" />
			</view>
			<view class="list_int">
				<text>联系电话：</text>
				<input type="text" v-model="phone" placeholder="请输入号码" />
			</view>
			<view class="list_int">
				<text>省/市/区：</text>
				<input type="text" v-model="address" placeholder="请输入地址" />
				<image src="https://t1.chowtaiking.com.cn/img/ruoyi/2023/12/19/c28dbe2eb7c346df98df586580d131a7.png" mode="widthFix"></image>
				
			</view>
			<view class="list_int">
				<text>详细街道：</text>
				<input type="text" v-model="street" placeholder="请输入详细街道" />
			</view>
			<view class="list_int">
				<text>地址标签：</text>

			</view>
			<view class="list_int">
				<text>设为默认：</text>

			</view>
			<button @click="saveAddress">保存</button>
		</view>

	</view>
</template>

<script>
	const app = getApp();
	export default{
		data(){
			return{
				name:'',
				phone:'',
				address:'',
				street:'',
				entryTime:0
			}
		},
		onShareAppMessage(res) {
			return {
				title: app.globalData.data.tenantName,
				path: "pages/user/user?numberId=" + app.globalData.data.numberId,
				mpId: app.globalData.data.appid
			}
		},
		onShow() {
			this.entryTime = Date.now();
		},
		onUnload() {
			this.OnEntryTime();
		},
		onLoad(params) {
			if(typeof(params)!='undefined'){
				var numberId = params.numberId || '';
				if(numberId != ''){
					uni.clearStorageSync();
					app.globalData.data.numberId = numberId;
				}
			}
			this.init();
		},
		methods:{
			init(e) {
				var user = app.globalData.get_user_info(this, "init", "");
				if (user != false) {
					if (app.globalData.user_is_need_login(user)) {
						uni.navigateTo({
							url:"/pages/login/login?event_callback=init"
						})
					} else {
						
					}
				}
			},
			OnEntryTime(){
				var radarlog_data = {
					pageUrl:"pages/user/user",
					name:"我的页面",
					remark:"我的页面停留时间",
					entryTime:this.entryTime,
				}
				uni.request({
					url:app.globalData.get_request_url("radarlog/add"),
					data:radarlog_data,
					method:"POST",
					success: (res) => {
						console.log(res);
					}
				})
			},
			saveAddress(){
				const addressInfo = {
					name:this.name,
					phone:this.phone,
					address:this.address,
					street:this.street
				}
				uni.setStorageSync('addressInfo',addressInfo)
				uni.navigateTo({
					url:"/pages/user-address/user-address?addressId=1"
				})
			}
		}
	}
</script>

<style>
	.address_add_input {
		width: 100%;
	}

	.inptTex {
		width: 90%;
		height: 80px;
		padding: 20rpx 20rpx 20rpx 20rpx;
		margin: 20rpx auto;
		background-color: #f4f4f4;
	}

	.input_but {
		display: flex;
		align-items: center;
		padding-right: 30rpx;
	}

	.but_item {
		width: 80px;
		height: 30px;
		text-align: center;
		line-height: 30px;
		border: 1px solid gray;
		border-radius: 10px;
		margin-left: 10px;
		margin-bottom: 20rpx;
	}

	.info_list {
		margin-left: 20rpx;
		border-top: 5px solid #f4f4f4;
	}

	.list_int {
		height: 50px;
		display: flex;
		align-items: center;
		font-size: 13px;
		border-bottom: 2px solid #f4f4f4;
	}

	.list_int input {
		width: 245px;
	}

	.list_int image {
		width: 40rpx;
	}

	.info_list button {
		width: 90%;
		height: 30px;
		line-height: 30px;
		text-align: center;
		background-color: red;
		border-radius: 20px;
		color: white;
		margin-top: 40rpx;
	}
</style>